<template>
    <div>
      <van-nav-bar left-text="返回" left-arrow @click-left="onClickLeft" class="back"/>
      <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
        <div class="main">
          <div class="rankContentType">
            <div class="content">
              <div class="shade">热歌</div>
            </div>
            <p></p>
          </div>
          <div class="rankContentTitle">{{name}}</div>
          <div class="rankContentTop">排行榜</div>
          <div class="rankContentList" v-for="(music,index) in musics" :key="index">
            <div class="first">{{index+1}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{music.title.length>20?music.title.substring(0,20)+'...':music.title}}</div>
            <div class="second">{{music.author}}</div>
          </div>
        </div>
      </van-pull-refresh>

    </div>
</template>

<script>
  export default {
    data(){
      return{
        musics:'',
        num:"",
        name:'',
        isLoading: false
      }
    },
    created(){
      this.name = this.$route.query.name
      console.log(this.name)
      this.num = this.$route.query.type
      this.$axios.get("https://api.apiopen.top/musicRankingsDetails?type="+this.num)
        .then(res => {
          /*console.log(res.data.result)*/
          this.musics = res.data.result
        })
      //获取歌曲内容
      /*this.$axios.get("https://api.apiopen.top/searchMusic?name="+this.l)*/
    },
    methods:{
      onClickLeft(){
        this.$router.go(-1)
      },
      onRefresh() {
        setTimeout(() => {
          this.$toast('刷新成功');
          this.isLoading = false;
          this.count++;
        }, 500);
      }
    }
  }
</script>

<style lang="less">
  .back {
    height: 4.4rem;
    line-height: 4.4rem;
    .van-nav-bar__left, .van-nav-bar__right {
      font-size: 1.5rem;
    }

    .van-nav-bar__title {
      font-size: 1.5rem;
    }

    .van-nav-bar__arrow {
      font-size: 1.5rem;
    }
  }
  .main{
    width: 100%;
    padding: 0 2rem;
    .rankContentType{
      padding-top: 5rem;
      width: 100%;
      text-align: center;
      .content{
        display: inline-block;
        width: 20rem;
        height: 20rem;
        background-image: url(http://img3.imgtn.bdimg.com/it/u=2092629866,904635697&fm=26&gp=0.jpg);
        .shade{
          width: 100%;
          height: 100%;
          line-height: 20rem;
          border-radius: 2rem;
          background-color: #000;
          opacity: 0.7;
          color: #fff;
          font-size: 5rem;
        }
      }

    }
    .rankContentTitle{
      padding-top: 3rem;
      text-align: center;
      font-size: 2rem;
    }
    .rankContentTop{
      padding-top: 2rem;
      font-size: 1.3rem;
      /*color: #999;*/
    }
    .rankContentList{
      padding-top: 1rem;
      padding-bottom: 1rem;
      .first{
        font-size: 1.5rem;
      }
      .second{
        font-size: 1.2rem;
        color: #999;
        padding-left: 4.2rem;
      }
    }
  }
</style>
